package com.ruoyi.info.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.info.domain.FhInfoCatchrecord;
import com.ruoyi.info.service.IFhInfoCatchrecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 渔获记录Controller
 * 
 * @author ruoyi
 * @date 2024-11-22
 */
@RestController
@RequestMapping("/info/catchrecord")
public class FhInfoCatchrecordController extends BaseController
{
    @Autowired
    private IFhInfoCatchrecordService fhInfoCatchrecordService;

    /**
     * 查询渔获记录列表
     */
    @PreAuthorize("@ss.hasPermi('info:catchrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(FhInfoCatchrecord fhInfoCatchrecord)
    {
        startPage();
        List<FhInfoCatchrecord> list = fhInfoCatchrecordService.selectFhInfoCatchrecordList(fhInfoCatchrecord);
        return getDataTable(list);
    }

    /**
     * 导出渔获记录列表
     */
    @PreAuthorize("@ss.hasPermi('info:catchrecord:export')")
    @Log(title = "渔获记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FhInfoCatchrecord fhInfoCatchrecord) throws IOException {
        List<FhInfoCatchrecord> list = fhInfoCatchrecordService.selectFhInfoCatchrecordList(fhInfoCatchrecord);
        ExcelUtil<FhInfoCatchrecord> util = new ExcelUtil<FhInfoCatchrecord>(FhInfoCatchrecord.class);
        util.exportExcel(response, list, "渔获记录数据");
    }

    /**
     * 获取渔获记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('info:catchrecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fhInfoCatchrecordService.selectFhInfoCatchrecordById(id));
    }

    /**
     * 新增渔获记录
     */
    @PreAuthorize("@ss.hasPermi('info:catchrecord:add')")
    @Log(title = "渔获记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FhInfoCatchrecord fhInfoCatchrecord)
    {
        return toAjax(fhInfoCatchrecordService.insertFhInfoCatchrecord(fhInfoCatchrecord));
    }

    /**
     * 修改渔获记录
     */
    @PreAuthorize("@ss.hasPermi('info:catchrecord:edit')")
    @Log(title = "渔获记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FhInfoCatchrecord fhInfoCatchrecord)
    {
        return toAjax(fhInfoCatchrecordService.updateFhInfoCatchrecord(fhInfoCatchrecord));
    }

    /**
     * 删除渔获记录
     */
    @PreAuthorize("@ss.hasPermi('info:catchrecord:remove')")
    @Log(title = "渔获记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fhInfoCatchrecordService.deleteFhInfoCatchrecordByIds(ids));
    }
}
